// 统一接口返回
export interface ITResponseData {
  // 返回状态
  success: boolean;

  // 错误信息
  message: string;

  // 返回数据
  data: any;

  // 返回码
  code: number;
}

export const dbUrl = "mongodb://localhost:27017/chemical";
// export const dbUrl = "mongodb://keiwnh2o3iuroot:isen4I3293eproot@118.31.21.163:27017/admin";

export const baseResp: ITResponseData = {
  success: true,
  message: "",
  data: null,
  code: 200,
};

export const badResp: ITResponseData = {
  success: false,
  message: "",
  data: null,
  code: 501,
};

/**
 * language
 */
export const langSchematype = {
  key: { type: String, required: true, unique: true },
  en: { type: String, required: true },
  cn: { type: String, required: true },
  desc: { type: String },
};
export const langModalname = "language";

/**
 * dictionary label
 */
export const dictLabelSchematype = {
  key: { type: String, required: true, unique: true },
  desc: { type: String },
};
export const dictLabelModalname = "dictionarylabel";

/**
 * dictionary value
 */
export const dictValueModalname = "dictionaryValue";
export const dictValueSchematype = {
  pid: { type: String, required: true },
  label: { type: String, required: true },
  cnlabel: { type: String, required: true },
  value: { type: String, required: true, unique: true },
  desc: { type: String },
  sort: { type: Number },
};

/**
 * reagent
 */
export const reagentModalname = "reagent";
export const reagentSchematype = {
  name: { type: String, required: true, unique: true },
  cnname: { type: String },
  formula: { type: String },
  casno: { type: String },
  type: { type: String, required: true },
  volatile: { type: Boolean },
  viscose: { type: Boolean },
  note: { type: String },
  density: { type: String },
  mw: { type: String },
  structural: { type: String },
  bp: { type: String },
  mp: { type: String },
  abbreviation: { type: String },
  percentage: { type: Number },
};

/**
 * reagent
 */
export const userReagentModalname = "userReagent";
export const userReagentSchematype = {
  name: { type: String, required: true, unique: true },
  cnname: { type: String },
  formula: { type: String },
  casno: { type: String },
  type: { type: String, required: true },
  volatile: { type: Boolean },
  viscose: { type: Boolean },
  note: { type: String },
  density: { type: String },
  mw: { type: String },
  structural: { type: String },
  bp: { type: String },
  mp: { type: String },
  abbreviation: { type: String },
  percentage: { type: Number },
  user: { type: String, required: true },
};

/**
 * user
 */
export const userModalname = "user";
export const userSchematype = {
  account: { type: String, required: true, unique: true },
  password: { type: String, required: true },
  privilege: { type: String, require: true },
  email: { type: String, require: true, unique: true },
};

/**
 * bottle
 */
export const bottleModalname = "bottle";
export const bottleSchematype = {
  name: { type: String, required: true, unique: true },
  height: { type: Number, required: true },
  diameter: { type: Number, require: true },
  depth: { type: Number, require: true },
  volume: { type: Number, require: true },
  shape: { type: String, require: true },
};

/**
 * shelf
 */
export const shelfModalname = "shelves";

export const shelfBottleSchematype = {
  name: { type: String, required: true },
  autox: { type: Number },
  autoy: { type: Number },
  diameter: { type: Number },
  rowIndex: { type: Number },
  colIndex: { type: Number },
  x: { type: Number },
  y: { type: Number },
};

export const shelfSchematype = (bottleSchema: any) => {
  return {
    name: { type: String, required: true, unique: true },
    rackType: { type: String, required: true },
    bottleType: { type: String, required: true },
    height: { type: Number, required: true },
    wide: { type: Number, required: true },
    length: { type: Number, required: true },
    row: { type: Number, required: true },
    column: { type: Number, required: true },
    offsetx: { type: Number, required: true },
    offsety: { type: Number, required: true },
    rowSpace: { type: Number, required: true },
    columnSpace: { type: Number, required: true },
    bottleList: { type: [bottleSchema], required: true },
  };
};

/**
 * workbench
 */
export const workbenchModalname = "workbench";

export const workbencSlotSchematype = {
  name: { type: String, required: true },
  x: { type: Number },
  y: { type: Number },
};

export const workbenchSchematype = (slotListSchema: any) => {
  return {
    name: { type: String, required: true, unique: true },
    row: { type: Number, required: true },
    column: { type: Number, required: true },
    rrow: { type: Number, required: true },
    rcolumn: { type: Number, required: true },
    slotList: { type: [slotListSchema], required: true },
  };
};

/**
 * designer
 */
export const designerModalname = "designer";

export const designerSchematype = {
  name: { type: String, required: true },
  workbench: { type: String, required: true },
  desc: { type: String },
  userInfo: {
    account: { type: String, required: true },
    id: { type: String, required: true },
  },
  step: { type: Number, require: true },

  // 插槽的试管架信息
  slotShelf: { type: String },
  reactorSlotShelf: { type: String },
  reagentsort: { type: String },

  // 实验试剂信息
  reagents: { type: String },

  // 反应试剂信息
  reactors: { type: String },

  // 反应温度
  temperature: { type: Number },

  // 反应时间
  reactionTime: { type: Number },

  // 预设工作台id
  expTable: { type: String },
};

/**
 * exp table
 */

export const expTableModalname = "exptable";

export const expTableSchematype = {
  name: { type: String, required: true, unique: true },
  desc: { type: String },
  workbench: { type: String, required: true },
  slotShelf: { type: String, required: true },
  reactorSlotShelf: { type: String, required: true },
};

export const reactDesignerModalname = "reaction";

export const reactDesignertype = {
  name: { type: String, required: true },
  plate: { type: String, required: true },
  designer: { type: String, required: true },
  reagentsort: { type: Array },
  slotreagent: { type: Object },
};
